/*
    IceCode toolkit - graphics
    Copyright (C) 2011 Alfredo 'IceCoder' Mungo

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/

#ifndef _ICECODE_GRAPHICS_WINDOW_HPP
#define _ICECODE_GRAPHICS_WINDOW_HPP

#include <X11/Xlib.h>
#include <string>
#include <array>
#include "XConnection.hpp"

namespace icecode {
  namespace graphics {

    class Window
    {
    public:
      /*
	DESCRIPTION:
	 Instantiates a window class from a reference (XID or another Window class).
       */
      Window(icecode::graphics::XConnection& conn, ::Window w) throw() : id(w), x(conn) {}
      Window(icecode::graphics::XConnection& conn, const icecode::graphics::Window& w) throw() : id(w.id), x(conn) {}

      /*
	DESCRIPTION:
	 Creates a new window.

	THROWS:
	 runtime_exception("Unable to create window")
      */
      Window(icecode::graphics::XConnection& conn, std::string title, unsigned int width, unsigned int height);

      /*
	Returns a [width, height] array.
      */
      std::array<unsigned int, 2> getSize();
      void setSize(unsigned int width, unsigned int height);

      void close();

      //Shows/hides the window.
      void setVisible(bool _show = true);

      //Returns the Window's XID
      ::Window operator *() { return id; }

    private:
      ::Window id;
      icecode::graphics::XConnection x;
    };
  }
}

#endif //_ICECODE_GRAPHICS_WINDOW_HPP
